﻿using db_manage.dll.manage;
using db_manage.model;
using System;
using System.Windows.Forms;

namespace db_manage.page
{
    public partial class form_db_info_filter : Form
    {
        private db_config_list db_config_list
        {
            get
            {
                return manage.db_manage_config?.db_config_list;
            }
        }

        public form_db_info_filter()
        {
            InitializeComponent();
            config_get();
        }

        private void config_get()
        {
            tb_con.Text = db_config_list.name_contains;
            tb_prefix.Text = db_config_list.name_prefix;
            tb_name.Text = db_config_list.name_list;
        }

        private void config_set()
        {
            if (db_config_list == null)
            {
                manage.db_manage_config.db_config_list = new model.db_config_list();
            }
            db_config_list.name_contains = tb_con.Text;
            db_config_list.name_prefix = tb_prefix.Text;
            db_config_list.name_list = tb_name.Text;
        }

        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_save_Click(object sender, EventArgs e)
        {
            config_set();
            manage.db_manage_config = manage.db_manage_config;
            MessageBox.Show("操作完成");
        }

        /// <summary>
        /// 输入完毕事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tb_Validated(object sender, EventArgs e)
        {
            config_set();
        }
    }
}
